-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added http proxy support #5
base: master
Are you sure you want to change the base?
Conversation
@@ -1,3 +1,3 @@ | |||
class TelegramBotMiddleware | |||
VERSION = "0.3.2" | |||
VERSION = "0.3.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/MutableConstant: Freeze mutable objects assigned to constants.
def send_to_telegram(path, query) | ||
log_debug("Sending to chat: #{path} - #{query}") | ||
self.class.post("/bot#{@config.token}/#{path}", query: query) | ||
options=@def_options.clone | ||
options[:query]=query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
def send_to_telegram(path, query) | ||
log_debug("Sending to chat: #{path} - #{query}") | ||
self.class.post("/bot#{@config.token}/#{path}", query: query) | ||
options=@def_options.clone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i | ||
if ! @config.proxy_user.nil? | ||
@def_options[:http_proxyuser][email protected]_user | ||
@def_options[:http_proxypass][email protected]_pass || '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@def_options[:http_proxyaddr][email protected]_addr | ||
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i | ||
if ! @config.proxy_user.nil? | ||
@def_options[:http_proxyuser][email protected]_user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
if ! @config.proxy_addr.nil? | ||
@def_options[:http_proxyaddr][email protected]_addr | ||
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i | ||
if ! @config.proxy_user.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/NegatedIf: Favor unless over if for negative conditions.
Layout/SpaceAfterNot: Do not leave space between ! and its argument.
@def_options={} | ||
if ! @config.proxy_addr.nil? | ||
@def_options[:http_proxyaddr][email protected]_addr | ||
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
# proxy settings | ||
@def_options={} | ||
if ! @config.proxy_addr.nil? | ||
@def_options[:http_proxyaddr][email protected]_addr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
@@ -41,6 +41,16 @@ def initialize(app, &_block) | |||
raise ArgumentError.new("Config error: host can't be null || empty.") if @config.host.nil? || @config.host.empty? | |||
raise ArgumentError.new("Config error: token can't be null || empty.") if @config.token.nil? || @config.token.empty? | |||
|
|||
# proxy settings | |||
@def_options={} | |||
if ! @config.proxy_addr.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/NegatedIf: Favor unless over if for negative conditions.
Layout/SpaceAfterNot: Do not leave space between ! and its argument.
@@ -41,6 +41,16 @@ def initialize(app, &_block) | |||
raise ArgumentError.new("Config error: host can't be null || empty.") if @config.host.nil? || @config.host.empty? | |||
raise ArgumentError.new("Config error: token can't be null || empty.") if @config.token.nil? || @config.token.empty? | |||
|
|||
# proxy settings | |||
@def_options={} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/SpaceAroundOperators: Surrounding space missing for operator =.
simple and fast (but working well) support for http proxy.